#include<stdio.h>
int  main()
{
	int  x,y,z;
	scanf("%d %d",&x,&y);
     z=y%x;
	 printf("%d",z); 
}

